import { Injectable } from '@angular/core'
import { MatSnackBar } from '@angular/material'

@Injectable()
export class AppSnackBarService {

  constructor(private snackBar: MatSnackBar) {
  }

  /**
   * 开启底部小弹窗
   * @param message 内容文本
   * @param action 按钮文本
   */
  public openLeftBottom(message: string, action: string): void {
    this.snackBar.open(message, action, {
      duration: 2000,
      panelClass: 'app-snack-bar',
      horizontalPosition: 'left',
      verticalPosition: 'bottom'
    })
  }

  public openRightTop(message: string, action: string): void {
    this.snackBar.open(message, action, {
      duration: 2000,
      panelClass: 'app-snack-bar',
      horizontalPosition: 'right',
      verticalPosition: 'top'
    })
  }
  public openLeftTop(message: string, action: string): void {
    this.snackBar.open(message, action, {
      duration: 2000,
      panelClass: 'app-snack-bar',
      horizontalPosition: 'left',
      verticalPosition: 'top'
    })
  }

  public openCenterTop(message: string, action: string): void {
    this.snackBar.open(message, action, {
      duration: 2000,
      panelClass: 'app-snack-bar',
      horizontalPosition: 'center',
      verticalPosition: 'top'
    })
  }

  public openCenterBottom(message: string, action: string): void {
    this.snackBar.open(message, action, {
      duration: 2000,
      panelClass: 'app-snack-bar',
      horizontalPosition: 'center',
      verticalPosition: 'bottom'
    })
  }
}
